// 文章接口模块
import request from "@/utils/request";

//  请求获取文章列表数据
export const getArticle = (params) => {
  return request({
    method: "GET",
    url: "/v1_0/articles",
    params,
  });
};

//  请求获取文章数据
export const getArticleDetails = (article_id) => {
  return request({
    method: "GET",
    url: `/v1_0/articles/${article_id}`,
  });
};

//  取消收藏文章
export const delCollection = (target) => {
  return request({
    method: "DELETE",
    url: `/v1_0/article/collections/${target}`,
  });
};

//  添加收藏文章
export const addCollection = (target) => {
  return request({
    method: "POST",
    url: `/v1_0/article/collections`,
    data: { target },
  });
};

//  为文章点赞
export const addlike = (target) => {
  return request({
    method: "POST",
    url: `/v1_0/article/likings`,
    data: { target },
  });
};

//  取消为文章点赞
export const dellike = (target) => {
  return request({
    method: "DELETE",
    url: `/v1_0/article/likings/${target}`,
  });
};
